package com.luu.game.dao.impl;

import com.luu.game.dao.LevelExpDao;
import com.luu.game.data.dto.LevelExpDTO;
import com.luu.game.data.entity.LevelExpEntity;
import com.luu.game.mapper.LevelExpMapper;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

@Component
public class LevelExpDaoImpl implements LevelExpDao {

    @Autowired
    private LevelExpMapper levelExpMapper;

    @Override
    public LevelExpDTO findByLevel(Integer level) {
        final LevelExpEntity entity = levelExpMapper.selectById(level);
        final LevelExpDTO returnDTO = new LevelExpDTO();
        BeanUtils.copyProperties(entity,returnDTO);
        return returnDTO;
    }

    @Override
    public void insertLevel(LevelExpDTO levelExpDTO) {
        final LevelExpEntity entity = new LevelExpEntity();
        BeanUtils.copyProperties(levelExpDTO,entity);
        levelExpMapper.insert(entity);
    }
}
